package com.wh.order.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 订单状态枚举类
 */
@AllArgsConstructor
@Getter
public enum OrderStatus {
    WAITING_FOR_REVIEW(0, "待审核"),
    WAITING_FOR_RECHECK(1, "待复审"),
    REVIEW_FAILED(2, "审核未通过"),
    WAITING_FOR_SHIPMENT(3, "待发货"),
    SHIPPED(4, "已发货"),
    TRANSACTION_SUCCESSFUL(5, "交易成功"),
    ORDER_CANCELLED(6, "订单取消"),
    WAITING_FOR_FINALREVIEWER(7,"待终审");
    private final Integer code;
    private final String description;



    // 根据状态码获取枚举值
    public static OrderStatus fromCode(int code) {
        for (OrderStatus status : OrderStatus.values()) {
            if (status.getCode() == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("Invalid OrderStatus code: " + code);
    }
}